import { Random } from "mockjs"; // 导出随机函数
import Mock from "mockjs";

function addTouristRoute(req: any) {
  return {
    success: true,
    message: "注册成功",
    code: "200",
    data: {},
  };
}

function getTouristRoute(req: any) {
  let data = Mock.Mock({
    id: "1",
    touristName: "@cname()",
    PhoneName: "@Integer(11111111,99999999999)",
    routeName: "@sentence()",
    travelDays: "@Integer(1,10)",
    departureLocation: "",
    departureTime: "",
    departureVehicle: "",
    returnLocation: "",
    returnTime: "",
    returnVehicle: "",
    travelInformations: {
      id: "2",
      travelDate: "",
      destination: "",
      hotelAccomodation: "",
      theatricalPerformance: "",
      price: "@Integer(1,99)",
      touristRouteId: "3",
      travelScenicInformations: [
        {
          id: "4",
          travelInformationId: "5",
          scenicSpotId: "6",
          scenicSpot: {
            id: "7",
            name: "@cname()",
            pictureUrl: "",
            description: "@sentence()",
            price: "@Integer(2,99)",
            belongCity: "8",
            cityId: "9",
          },
        },
      ],
    },
  });

  console.log(data.data);

  return {
    success: true,
    message: "注册成功",
    code: "200",
    data,
  };
}

function updateTouristRoute(req: any) {
  return {
    success: true,
    message: "更新成功",
    code: "200",
    data: {},
  };
}

function getAllTourist() {
  let { data } = Mock.mock({
    "data|1-7": [
      {
        id: "1",
        touristName: "@cname()",
        phoneNum: "@Integer(11111111111,11999999999)",
        routeName: "@ctitle(2,7)",
        travelDays: "@Integer(1,10)",
        departureLocation: "",
        departureTime: "",
        departureVehicle: "",
        returnLocation: "",
        returnTime: "",
        returnVehicle: "",
        creater: "@cname()",
        "travelInformations|3-6": [
          {
            id: "1",
            travelDate: "1",
            destination: "@ctitle(4,7)",
            hotelAccomodation: "@ctitle(3,7)",
            theatricalPerformance: "@ctitle(2,8)",
            price: "@Integer(1,99)",
            touristRouteId: "3",
            order: "@Integer(0,10)",
            vehicle: Random.pick([
              "奔驰7座",
              "别克",
              "九座商务车",
              "18座大巴车",
              "的士车",
              "私家车",
            ]),
            "travelScenicInformations|3-5": [
              {
                id: "4",
                travelInformationId: "5",
                scenicSpotId: "6",
                scenicSpot: {
                  id: "7",
                  name: "@cname()",
                  pictureUrl: "",
                  description: "@sentence()",
                  price: "@Integer(2,99)",
                  belongCity: "8",
                  cityId: "9",
                },
              },
            ],
          },
        ],
      },
    ],
  });

  return {
    success: true,
    message: "更新成功",
    code: "200",
    data: {
      data: data,
      total: 50,
    },
  };
}

function deleteTouristRoute() {
  return {
    success: true,
    message: "更新成功",
    code: "200",
    data: null,
  };
}

export default {
  addTouristRoute,
  getTouristRoute,
  updateTouristRoute,
  getAllTourist,
  deleteTouristRoute,
};
